<!--
**********************************************************
* @Author: 张小平
* @Date:   2024-05-01
* @Email:  qqshuqian@163.com
* @Last modified: 最后修改日期
* @Description: 文件描述
**********************************************************
-->
<template>
  <div class="execution">
    <basic-container>
      <avue-crud
              v-model="form"
              v-model:search="searchForm"
              v-model:page="page"
              :permission="getPermission"
              v-bind="bindVal"
              v-on="onEvent"
              :option="option"
              :data="tableData"
              :before-open="beforeOpen"
      >
          <template #menu="scope">
            <el-button v-if="scope.row.type=='xlsx'|| scope.row.type=='xls'" link type="primary"  size="small" icon="el-icon-lock" @click="downFileHander(scope.row,scope.index)">下载</el-button>

            <el-button v-if="scope.row.type=='png'|| scope.row.type=='jpg'" link type="primary"  size="small" icon="el-icon-lock" @click="showFile(scope.row,scope.index)">查看</el-button>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
    import {tableOption} from './file'
    import crud from "@/framework-core/mixins/crud";

    export default {
        name: 'sysfile',
        mixins: [crud],
        data() {
            return {
                pageConfig:{"url":"sys/file"},
                searchForm: {},
                loading: false,
                form:{},
                option: tableOption,
                imgdatas:[],


            }
        },
        computed: {
             ...mapState({
                permissions: (state) =>state.user.permission,
            })

        },
        methods: {
            getPermission: function (key, row, index) {
                return this.getCommPermission(key, row, index);
            },
            showFile: function (row, index) {
                let datas = [];
                let  index2=0;
                datas.push({ thumbUrl: row.url, url: row.url })
                this.$ImagePreview(datas, index2, {
                    closeOnClickModal: true,
                    click: (data, index2) => {
                        this.$message.success('点击事件' + index2)
                    },
                    beforeClose: () => {
                        this.$message.success('关闭回调')
                    }
                });
            },
          downFileHander: function (row, index) {
            this.downFile( row.url);
          }
        }
    }
</script>
